package com.dindang.checkline.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dindang.checkline.di.module.LineDetailModule;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import com.dindang.checkline.di.component.DaggerLineDetailComponent;
import com.dindang.checkline.mvp.contract.LineDetailContract;
import com.dindang.checkline.mvp.presenter.LineDetailPresenter;

import com.dindang.checkline.R;


import static com.jess.arms.utils.Preconditions.checkNotNull;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 03/26/2019 15:36
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
public class LineDetailActivity extends BaseActivity<LineDetailPresenter> implements LineDetailContract.View {
    TextView mTvTitle;
    RecyclerView mRecyclerView;
    ImageView mIvBack;
    RelativeLayout mRlupddate;
    TextView mtvUpdataeNum;
    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerLineDetailComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .lineDetailModule(new LineDetailModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_line_detail; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mIvBack = findViewById(R.id.maintenance_iv_back);
        mTvTitle =  findViewById(R.id.maintenance_tv_title);
        mRecyclerView = findViewById(R.id.recyclerView);
        mRlupddate = findViewById(R.id.update_rl);
        mtvUpdataeNum = findViewById(R.id.updata_num);
        mTvTitle.setText("巡检概况");
        mTvTitle.setOnClickListener(v -> finish());
        mIvBack.setOnClickListener(v -> finish());
        mPresenter.init();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public TextView getTvTitle() {
        return mTvTitle;
    }

    @Override
    public RecyclerView getRecyclerView() {
        return mRecyclerView;
    }

    @Override
    public ImageView getIvBack() {
        return mIvBack;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }
    @Override
    public RelativeLayout getRlupddate() {
        return mRlupddate;
    }

    @Override
    public TextView gettvUpdataeNum() {
        return mtvUpdataeNum;
    }
}
